package org.todd.healthreport.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.todd.healthreport.service.IHealthReportService;

@Controller
@Api(tags = "健康报备")
public class HealthReportController {

    @Autowired
    private IHealthReportService healthReportService;

    @GetMapping(value = "healthReport",produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "配置文件身份证报备",notes = "")
    @ResponseBody
    public String allHealthReport(){
        JSONObject json = new JSONObject();
        healthReportService.healthReport();
        json.put("code",200);
        json.put("flag",true);
        json.put("msg","全体报备成功");
        System.out.println(json.toJSONString());
        return json.toJSONString();
    }

    @GetMapping(value = "healthReportByIdcard",produces = {"application/json;charset=UTF-8"})
    @ApiOperation(value = "单个身份证报备",notes = "")
    @ApiImplicitParam(required = true,name = "idCard",value = "身份证号码",paramType = "query")
    @ResponseBody
    public String healthReportByIdCard(@RequestParam String idCard){
        JSONObject json = new JSONObject();
        String s = healthReportService.reportHandel(idCard);
        json.put("code",200);
        json.put("flag",true);
        json.put("msg",idCard+"-"+s+":报备成功");
        System.out.println(json.toJSONString());
        return json.toJSONString();
    }

}
